/*
 *  Gurr - A multiprotocol chat client for Android
 *  Copyright (C) 2011 Malte Aschermann, Wilfried Ramaker
 *  
 *  This file is part of Gurr.
 *  
 *  Gurr is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU Lesser General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *  
 *  Gurr is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU Lesser General Public License for more details.
 *  
 *  You should have received a copy of the GNU Lesser General Public License
 *  along with Gurr.  If not, see <http://www.gnu.org/licenses/>.
 */

package com.masc.gurr.model;

import net.kano.joscar.snaccmd.FullUserInfo;

public class ContactStatus {
	
	private long status;
	
	public ContactStatus(long status) {
		this.status = status;
	}
	
	@Override
	public String toString() {
		
		/*
		long state = status;
		long away = status & FullUserInfo.ICQSTATUS_AWAY;
		long dnd = status & FullUserInfo.ICQSTATUS_DND;
		long ffc = status & FullUserInfo.ICQSTATUS_FFC;
		long inv = status & FullUserInfo.ICQSTATUS_INVISIBLE;
		long occ = status & FullUserInfo.ICQSTATUS_OCCUPIED;
		*/
		
		if ((status & FullUserInfo.MASK_ALL) == FullUserInfo.MASK_ALL)
			return "OFFLINE";
		
		if ((status & FullUserInfo.ICQSTATUS_AWAY) == FullUserInfo.ICQSTATUS_AWAY) { /* test for DND/NA/OCC */
			
			if ((status & FullUserInfo.ICQSTATUS_DND) == FullUserInfo.ICQSTATUS_DND)
				return "DND";
			
			else if ((status & FullUserInfo.ICQSTATUS_NA) == FullUserInfo.ICQSTATUS_NA)
				return "NA";
			
			else if ((status & FullUserInfo.ICQSTATUS_OCCUPIED) == FullUserInfo.ICQSTATUS_OCCUPIED)
				return "OCCUPIED";
			
			else
				return "AWAY";
		}
		
		else if ((status & FullUserInfo.ICQSTATUS_INVISIBLE) == FullUserInfo.ICQSTATUS_INVISIBLE)
			return "INVISIBLE";
		
		else if ((status & FullUserInfo.ICQSTATUS_FFC) == FullUserInfo.ICQSTATUS_FFC)
			return "FFC";
		
		else /* every other status id defaults to 'online' */
			return "ONLINE";
			
	}

	public long getStatus() {
		return status;
	}

	public void setStatus(long status) {
		this.status = status;
	}
	
}
